		TITLE	CSUBS	- Copyright (c) SLR Systems 1994

		INCLUDE MACROS
if	fg_slrpack
		INCLUDE SLR32


		PUBLIC	SLR_MOVER


		.DATA

		EXTERNDEF	SLR_INBUF_LIMIT:DWORD,SLR_BYTES_LEFT:DWORD,SLR_INPUT_PTR_OFFSET:DWORD,SLR_INPUT_PTR_BASE:DWORD


		.CODE	PASS2_TEXT

		EXTERNDEF	CONVERT_SUBBX_TO_EAX:PROC,RELEASE_BLOCK:PROC


SLR_MOVER	PROC
		;
		;USE SMALLER OF ECX AND BYTES_LEFT
		;		EDI IS DESTINATION
		;
		PUSH	ESI
		MOV	EAX,SLR_BYTES_LEFT

		CMP	EAX,ECX
		JAE	L1$

		MOV	ECX,EAX
L1$:
		;
		;MOVE ECX BYTES FROM SLR_INPUT_PTR TO EDI
		;
		PUSH	EBX
		MOV	ESI,SLR_INPUT_PTR_OFFSET

		SUB	EAX,ECX
		MOV	EBX,SLR_INPUT_PTR_BASE

		MOV	SLR_BYTES_LEFT,EAX
L2$:
		;
		;NOW MOVE SMALLER OF PAGE_SIZE-ESI AND ECX
		;
		MOV	EAX,PAGE_SIZE

		SUB	EAX,ESI

		CMP	EAX,ECX
		JB	L3$

		MOV	EAX,ECX
L3$:
		PUSHM	ECX,EAX

		MOV	ECX,EAX
		CALL	CONVERT_SUBBX_TO_EAX

		ADD	ESI,EAX

		OPTI_MOVSB

		SUB	ESI,EAX
		POPM	EAX,ECX

		CMP	ESI,PAGE_SIZE
		JNZ	L4$

		PUSH	EAX
		XOR	EDX,EDX

		MOV	EAX,[EBX]
		CALL	RELEASE_BLOCK

		MOV	[EBX],EDX
		ADD	EBX,4

		POP	EAX
		MOV	SLR_INPUT_PTR_BASE,EBX

		XOR	ESI,ESI
		SUB	ECX,EAX

		JNZ	L2$
L4$:
		MOV	SLR_INPUT_PTR_OFFSET,ESI
		MOV	EAX,SLR_BYTES_LEFT
		;
		;IF SLR_BYTES_LEFT=0, RELEASE LAST BLOCK
		;
		TEST	EAX,EAX
		JNZ	L5$

		MOV	EAX,[EBX]
		XOR	EDX,EDX

		TEST	EAX,EAX
		JZ	L5$

		MOV	[EBX],EDX
		CALL	RELEASE_BLOCK
L5$:
		POPM	EBX,ESI

		MOV	SLR_INBUF_LIMIT,EDI

		RET

SLR_MOVER	ENDP

endif

		END

